package com.fmi.cloud.biz;

import com.alibaba.fastjson.JSONObject;
import com.fmi.cloud.util.JSONHelper;
import com.fmi.cloud.util.SpUtil;

/**
 * Created by zv on 2017-12-6.
 */

public class CommonSp {

    public static void setUserInfo(String userInfo) {
        SpUtil.getInstance().putString("USER_INFO", userInfo);
    }

    public static String getUserInfo() {
        String json = SpUtil.getInstance().getString("USER_INFO");
        if (!"".equals(json)) {
            JSONObject jo = JSONObject.parseObject(json);
            json = jo.toJSONString();
        }
        return json;
    }

    public static void setData(String data) {
        SpUtil.getInstance().putString("DATA", data);
    }

    public static String getData() {
        return SpUtil.getInstance().getString("DATA");
    }

    // 1 不是第一次 0 第一次
    public static void setFirst(String isFirstLogin) {
        SpUtil.getInstance().putString("IS_FIRST", isFirstLogin);
    }

    public static boolean isFirst() {
        String first = SpUtil.getInstance().getString("IS_FIRST", "0");
        return "0".equals(first);
    }

    public static void setUserID(String userID) {
        SpUtil.getInstance().putString("USER_ID", userID);
    }

    public static String getUserID() {
        return SpUtil.getInstance().getString("USER_ID", "");
    }


    public static void setBrokerID(String brokerID) {
        SpUtil.getInstance().putString("BROKER_ID", brokerID);
    }

    public static String getBrokerID() {
        return SpUtil.getInstance().getString("BROKER_ID", "");
    }

    public static void setAgentID(String agentID) {
        SpUtil.getInstance().putString("AGENT_ID", agentID);
    }

    public static String getAgentID() {
        return SpUtil.getInstance().getString("AGENT_ID", "");
    }

    public static void setProvinceID(String provinceID) {
        SpUtil.getInstance().putString("PROVINCE_ID", provinceID);
    }

    public static String getProvinceID() {
        return SpUtil.getInstance().getString("PROVINCE_ID", "");
    }

    public static void setCityID(String cityID) {
        SpUtil.getInstance().putString("CITY_ID", cityID);
    }

    public static String getCityID() {
        return SpUtil.getInstance().getString("CITY_ID", "");
    }


    public static void setOperatorID(String operatorID) {
        SpUtil.getInstance().putString("OPERATOR_ID", operatorID);
    }

    public static String getOperatorID() {
        return SpUtil.getInstance().getString("OPERATOR_ID", "");
    }
}
